<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<div id="profile">
    <div id="logo">
        <?php echo CHtml::link(CHtml::image('images/logo.png', 'private sale'), array('/m/index')) ?>
    </div>
    <div class="input">
        <form id="send" action="<?php echo $this->createUrl("/m/profile") ?>" method="POST">
            <?php echo CHtml::textField("email",'', array("placeholder"=>"Email của bạn")) ?>
        </form>
    </div>
    <div class="button">
        <?php echo CHtml::link(CHtml::image("images/login.jpg"), "#", array("onclick"=>"sendEmail()")) ?>
        <?php if ($check): ?>
            <span style="color:red; position:absolute; left:210px; top:-26px; width:150px"><i>Email này chưa đăng ký</i></span>
        <?php endif ?>
    </div>
    <div class="text-register">
        Bạn chưa tham gia? Hãy <?php echo CHtml::link("click vào đây", array("/m/index"), array("style"=>"text-decoration: none;font-style: italic;color:#cb2d78")) ?>
    </div>
    <div class="name">
        <b>[<?php echo $name ?>]</b>
    </div>
    <div class="share">
        <div>Chào [<?php echo $name ?>], bạn có cơ hội trúng voucher</div>
        <div><b>100.000 VNĐ </b>hoặc<b> 500.000 VNĐ!</b></div>
        <div>Rất đơn giản, chỉ cần chia sẻ link dưới đây cho bạn bè!</div>
        <div class="link-share">
            <?php echo CHtml::textField("link",$referral_link, array("style"=>"margin-left: 7px;margin-top: 5px;width: 240px; border:0px")) ?>
        </div>
        <div id="social-link">
            <span class='st_facebook_large' displayText='Facebook' st_url="<?php echo Yii::app()->createAbsoluteUrl('/m/index',array('ref_id'=>$referral_id)) ?>"></span>

            <span class='st_twitter_large' displayText='Tweet' st_url="<?php echo Yii::app()->createAbsoluteUrl('/m/index',array('ref_id'=>$referral_id)) ?>"></span>

            <span class='st_linkedin_large' displayText='LinkedIn' st_url="<?php echo Yii::app()->createAbsoluteUrl('/m/index',array('ref_id'=>$referral_id)) ?>"></span>

            <span class='st_googleplus_large' displayText='Google +' st_url="<?php echo Yii::app()->createAbsoluteUrl('/m/index',array('ref_id'=>$referral_id)) ?>"></span>

        </div>
    </div>
</div>

<script type="text/javascript">
    function sendEmail()
    {
        if(validateForm())
            $("#send").submit();
        return false;
    }

    function validateForm()
    {
        var x=document.forms["send"]["email"].value;
        var atpos=x.indexOf("@");
        var dotpos=x.lastIndexOf(".");
        if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
        {
            alert("Email không hợp lệ");
            return false;
        }
        return true;
    }
</script>

